<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2021/1/28
 * Time: 20:16
 */
declare(strict_types=1);

namespace App\Controller\AdminApi;

use App\Service\CommonService;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Annotation\Controller;
use Hyperf\HttpServer\Annotation\PostMapping;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\Logger\LoggerFactory;
use Hyperf\Validation\Contract\ValidatorFactoryInterface;

/**
 * Class MchInfoController
 * @package App\Controller
 *
 * @Controller(prefix="/admin/api/common")
 */
class CommonController extends AdminBaseController
{
    /**
     * @Inject()
     * @var ValidatorFactoryInterface
     */
    protected $validationFactory;

    /**
     * @Inject()
     * @var CommonService
     */
    protected $CommonService;

    /**
     * @var \Psr\Log\LoggerInterface
     */
    protected $logger;

    public function __construct(LoggerFactory $loggerFactory)
    {
        // 第一个参数对应日志的 name, 第二个参数对应 config/autoload/logger.php 内的 key
        $this->logger = $loggerFactory->get('log', 'default');
    }

    /**
     * ali-oss临时凭证
     * @PostMapping(path = "aliOssTmpKey")
     */
    public function aliOssTmpKey(RequestInterface $request)
    {
        return $this->CommonService->aliOssTmpKey();
    }

}